I figured it out in the end and this is the code I used:
function restrict_menus() {
$author = wp_get_current_user();
if( isset( $author->roles[0] ) ) {
$current_role = $author->roles[0];
} else {
$current_role="no_role";
}
if( 'contributor' == $current_role ) {
$screen = get_current_screen();
$base = $screen->id;
if( 'edit-post' == $base || 'upload' == $base || 'tools' == $base || 'edit-comments' == $base ) {
wp_die( 'Cheatin’ uh?' );
}
}
}
add_action( 'current_screen', 'restrict_menus' );